package com.xiaohudie.SGGJUC;

import java.util.concurrent.*;

/**
 * @Author xiao hu die
 * @Date 2022/3/10 15:32
 * @Version 1.0
 */
public class TestThreadPool {
 public static void main(String[] args) {
  ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
          2,
          5,
          3,
          TimeUnit.SECONDS,
          new ArrayBlockingQueue<>(3),
          Executors.defaultThreadFactory(),
          new ThreadPoolExecutor.CallerRunsPolicy()
  );
  try {
   for (int i = 0; i <10 ; i++) {
   threadPoolExecutor.execute(()->{
    System.out.println(Thread.currentThread().getName());
   });
  }}finally {
   threadPoolExecutor.shutdown();
  }
 }
}
